/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2019
 */

package com.jzwl.site.wap.wxUser.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jzwl.common.constant.AjaxStatusConstant;
import com.jzwl.site.wap.wxUser.service.WxUserService;
import com.jzwl.system.base.controller.BaseController;

/**
 * WxUser
 * WxUser
 * wxUser
 * <p>Title:WxUserController </p>
 * 	<p>Description:WxUser </p>
 * 	<p>Company: </p> 
 * 	@author aotu-code 
 */
@Controller("wxUser")
@RequestMapping("/wxUser")
public class WxUserController extends BaseController {

	@Autowired
	private WxUserService wxUserService;

	/**
	 * 首次关注存储用户信息
	 * @param request
	 * @param response
	 * @return TODO(这里描述每个参数,如果有返回值描述返回值,如果有异常描述异常)
	 */
	@RequestMapping(value = "/addWxUser")
	public @ResponseBody Map<String, Object> addWxUser(HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			createParameterMap(request);
			boolean flag = wxUserService.addWxUser(paramsMap);
			if (flag) {
				resultMap.put("msg", AjaxStatusConstant.AJAX_STATUS_SUCCESS);
				resultMap.put("code", AjaxStatusConstant.AJAX_CODE_SUCCESS);
				resultMap.put("resourceInfo", "添加成功");
			} else {
				resultMap.put("msg", AjaxStatusConstant.AJAX_STATUS_FAILURE);
				resultMap.put("code", AjaxStatusConstant.AJAX_CODE_FAILE);
				resultMap.put("resourceInfo", "添加失败");
			}
		} catch (Exception e) {
			resultMap.put("msg", AjaxStatusConstant.AJAX_STATUS_FAILURE);
			resultMap.put("code", AjaxStatusConstant.AJAX_CODE_FAILE);
			resultMap.put("resourceInfo", "添加失败");
		}
		return resultMap;
	}

	/**
	 * 通过openId获取用户信息
	 * @param request
	 * @param response
	 * @return TODO(这里描述每个参数,如果有返回值描述返回值,如果有异常描述异常)
	 */
	//	@RequestMapping(value = "/queryWxUser")
	//	public @ResponseBody Map<String, Object> queryUserInfoByOpenId(HttpServletRequest request,
	//			HttpServletResponse response) {
	//		Map<String, Object> resultMap = new HashMap<String, Object>();
	//		try {
	//			createParameterMap(request);
	//			Map<String, Object> userInfo = wxUserService.queryUserInfoByOpenId(paramsMap);
	//			resultMap.put("msg", AjaxStatusConstant.AJAX_STATUS_SUCCESS);
	//			resultMap.put("code", AjaxStatusConstant.AJAX_CODE_SUCCESS);
	//			resultMap.put("resourceInfo", userInfo);
	//		} catch (Exception e) {
	//			resultMap.put("msg", AjaxStatusConstant.AJAX_STATUS_FAILURE);
	//			resultMap.put("code", AjaxStatusConstant.AJAX_CODE_FAILE);
	//			resultMap.put("resourceInfo", "添加失败");
	//		}
	//		return resultMap;
	//	}

	//auto-code-end

}
